package com.lhy.wcss.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lhy.wcss.model.domain.Dictionary;
import com.lhy.wcss.mapper.DictionaryMapper;
import com.lhy.wcss.service.DictionaryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {

    @Override
    public List<Dictionary> getByType(String type) {
        QueryWrapper<Dictionary> wrapper=new QueryWrapper<>();
        wrapper.lambda().eq(Dictionary::getType,type).isNotNull(Dictionary::getItemValue);
        List<Dictionary> list = this.list(wrapper);
        return list;
    }

    @Override
    public String getByNameAndType(String name, String type) {
        QueryWrapper<Dictionary> wrapper=new QueryWrapper<>();
        wrapper.lambda().eq(Dictionary::getItemName,name).eq(Dictionary::getType,type);
        Dictionary one = this.getOne(wrapper);
        return one.getItemValue();
    }


}
